Conditions | 1 |
Paths | 1 |
Total Lines | 62 |
Lines | 62 |
Ratio | 100 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | View Code Duplication | var assert = require('chai').assert, |
|
115 | it('Build', function(){ |
||
116 | var description = GedcomX.SourceDescription() |
||
117 | .setResourceType('http://some/type') |
||
118 | .addCitation(GedcomX.SourceCitation().setLang('en').setValue('Long source citation')) |
||
119 | .setMediaType('book') |
||
120 | .setAbout('http://a/resource') |
||
121 | .setMediator(GedcomX.ResourceReference().setResource('http://mediator')) |
||
122 | .addSource(GedcomX.SourceReference().setDescription('http://source/reference')) |
||
123 | .setAnalysis(GedcomX.ResourceReference().setResource('http://analysis')) |
||
124 | .setComponentOf(GedcomX.SourceReference().setDescription('http://container')) |
||
125 | .addTitle(GedcomX.TextValue().setLang('en').setValue('Title')) |
||
126 | .addTitle(GedcomX.TextValue().setLang('es').setValue('Titulo')) |
||
127 | .addNote(GedcomX.Note().setSubject('Note').setText('Some note text')) |
||
128 | .setAttribution(GedcomX.Attribution().setCreated(1234578129)) |
||
129 | .addRight(GedcomX.ResourceReference().setResource('https://some/right')) |
||
130 | .setCoverage( |
||
131 | GedcomX.Coverage() |
||
132 | .setTemporal(GedcomX.Date().setFormal('+2015')) |
||
133 | .setSpatial(GedcomX.PlaceReference().setOriginal('A place')) |
||
134 | ) |
||
135 | .addDescription(GedcomX.TextValue().setValue('A description')) |
||
136 | .setIdentifiers(GedcomX.Identifiers({ |
||
137 | $: 'identifier' |
||
138 | })) |
||
139 | .setCreated(1000000) |
||
140 | .setModified(11111111) |
||
141 | .setSortKey('123456') |
||
142 | .setVersion('123') |
||
143 | .setRepository(GedcomX.ResourceReference().setResource('http://repository')); |
||
144 | assert.equal(description.getResourceType(), 'http://some/type'); |
||
145 | assert.equal(description.getCitations().length, 1); |
||
146 | assert.equal(description.getCitations()[0].getLang(), 'en'); |
||
147 | assert.equal(description.getCitations()[0].getValue(), 'Long source citation'); |
||
148 | assert.equal(description.getMediaType(), 'book'); |
||
149 | assert.equal(description.getAbout(), 'http://a/resource'); |
||
150 | assert.equal(description.getMediator().getResource(), 'http://mediator'); |
||
151 | assert.equal(description.getSources().length, 1); |
||
152 | assert.equal(description.getSources()[0].getDescription(), 'http://source/reference'); |
||
153 | assert.equal(description.getAnalysis().getResource(), 'http://analysis'); |
||
154 | assert.equal(description.getComponentOf().getDescription(), 'http://container'); |
||
155 | assert.equal(description.getTitles().length, 2); |
||
156 | assert.equal(description.getTitles()[0].getLang(), 'en'); |
||
157 | assert.equal(description.getTitles()[0].getValue(), 'Title'); |
||
158 | assert.equal(description.getTitles()[1].getLang(), 'es'); |
||
159 | assert.equal(description.getTitles()[1].getValue(), 'Titulo'); |
||
160 | assert.equal(description.getNotes().length, 1); |
||
161 | assert.equal(description.getNotes()[0].getSubject(), 'Note'); |
||
162 | assert.equal(description.getNotes()[0].getText(), 'Some note text'); |
||
163 | assert.equal(description.getAttribution().getCreated().getTime(), 1234578129); |
||
164 | assert.equal(description.getRights().length, 1); |
||
165 | assert.equal(description.getRights()[0].getResource(), 'https://some/right'); |
||
166 | assert.equal(description.getCoverage().getTemporal().getFormal(), '+2015'); |
||
167 | assert.equal(description.getCoverage().getSpatial().getOriginal(), 'A place'); |
||
168 | assert.equal(description.getDescriptions().length, 1); |
||
169 | assert.equal(description.getDescriptions()[0].getValue(), 'A description'); |
||
170 | assert.equal(description.getIdentifiers().identifiers.$, 'identifier'); |
||
171 | assert.equal(description.getCreated(), 1000000); |
||
172 | assert.equal(description.getModified(), 11111111); |
||
173 | assert.equal(description.getSortKey(), '123456'); |
||
174 | assert.equal(description.getVersion(), '123'); |
||
175 | assert.equal(description.getRepository().getResource(), 'http://repository'); |
||
176 | }); |
||
177 | |||
183 | }); |